import Vue from "vue"
import VueRouter from "vue-router"



// 0.全局注册使用 VueRouter
Vue.use(VueRouter)


// 1.路由组件
import errorRoute from "@/views/errorpages/route"
import mainRoute from "@/views/main/route"
import loginRoute from "@/views/logins/route"

import searchRoute from "@/views/search/route"



// 2.定义路由选项
const routes = [
  {
    path: "/",
    redirect: "/main"
  },



  {
    path: "/logins",
    name: "logins",
    component: () => import("@/views/logins/logins.vue")
  },

  ...errorRoute,
  ...mainRoute,
  ...loginRoute,
  ...searchRoute,
  {
    path: "*",
    redirect: "/404"
  }
]

// 3. 创建路由
const router = new VueRouter({
  mode: 'hash',
  routes,
  base: ""
})

// 4. 挂载到根实例
export default router;
